<?php

namespace App\Services\WeChat\Templates;
use App\Services\WeChat\MessageDispatcher;

class AppointFailTemplate extends BaseTemplate
{
    protected $name;
    protected $type;
    protected $hospital;
    protected $datetime;
    protected $date;
    protected $page = 'pages/index/index';

    // 就诊人姓名
    public function name(string $name): self
    {
        $this->name = $name;
        return $this;
    }

    // 就诊医院
    public function hospital(string $hospital): self
    {
        $this->hospital = $hospital;
        return $this;
    }
    // 就诊时间
    public function datetime(string $datetime): self
    {
        $this->datetime = $datetime;
        return $this;
    }
    // 就诊时间
    public function info(string $info): self
    {
        $this->info = $info;
        return $this;
    }
    // 提示说明
    public function type(string $type): self
    {
        $this->type = $type;
        return $this;
    }

    // 设置跳转页面
    public function page(string $path): self
    {
        $this->page = $path;
        return $this;
    }

    public function send(): void
    {
        $this->dispatcher->send('mini', $this->openid, [
            'name6' => ['value'=>$this->name],
            'thing9' => ['value'=>$this->type],
            'thing7' => ['value'=>$this->hospital],
            'time1' => ['value'=>$this->datetime],
            'thing5' => ['value'=>$this->info],
            'temp_id' => 3,
            'page' => $this->page
        ]);
    }
}
